package com.yuanjin.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.yuanjin.R;

public/******************** 内部 adapter 类 ***********************/
class FriendShow_ImageAddAdapter extends BaseAdapter {
	private Context context;
	private LayoutInflater inflater;
	// private Vector<uploadshowimagesItem> vector;
	private ArrayList<Object> list;

	public FriendShow_ImageAddAdapter(Context context, ArrayList<Object> list) {
		this.context = context;
		this.inflater = LayoutInflater.from(context);
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// View view = inflater.inflate(
		// R.layout.griditeminfo_friendshowupload, null);
		// ((ImageView) view.findViewById(R.id.gv_itemImage))
		// .setImageResource((Integer) list.get(position));
		// if (position!=list.size()-1) {
		// ((ImageView)
		// view.findViewById(R.id.gv_itemImage)).setVisibility(view.VISIBLE);
		// }else {
		// ((ImageView)
		// view.findViewById(R.id.gv_itemImagelast)).setVisibility(view.VISIBLE);
		// }

		View view;
		if (position != list.size() - 1) {

			view = inflater.inflate(R.layout.griditeminfo_friendshowupload,
					null);
			// ((ImageView) view.findViewById(R.id.gv_itemImage))
			// .setImageResource((Integer) list.get(position));
			((ImageView) view.findViewById(R.id.gv_itemImage))
					.setImageBitmap((Bitmap) list.get(position));
		} else {
			if (list.get(position) instanceof Bitmap) {
				view = inflater.inflate(R.layout.griditeminfo_friendshowupload,
						null);
				// ((ImageView) view.findViewById(R.id.gv_itemImage))
				// .setImageResource((Integer) list.get(position));
				((ImageView) view.findViewById(R.id.gv_itemImage))
						.setImageBitmap((Bitmap) list.get(position));
			}else {
				view = inflater.inflate(R.layout.griditeminfo_friendshowupload2,
						null);
			}

		}

		return view;
	}

}